/*
 * @lc app=leetcode.cn id=744 lang=cpp
 *
 * [744] 寻找比目标字母大的最小字母
 */

// @lc code=start
#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
    char nextGreatestLetter(vector<char> &letters, char target)
    {
        char ans = 127;
        for (auto c : letters)
        {
            if (c > target)
                ans = std::min(c, ans);
        }
        if (ans == 127) return letters[0];
        else return ans;
    }
};
// @lc code=end
